﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using weiqijiance.model.安检联网;

namespace weiqijiance.安检联网
{
    public class ajlwbass
    {
        public mainform m_mainform;// = new mainform("");
        public string photosIP;
        public int photosPort;//cjm
        public string ssfAJLW = "否";
        public string sweb = "";
        public string ssqm = "";
        public string jyjgbh = "";
       
        public string ssqqzr = "";

        public string decode(string str)//utf8转中文
        {
            Encoding utf8 = Encoding.UTF8;
            // 首先用utf-8进行解码                    
            return HttpUtility.UrlDecode(str.ToUpper(), utf8);
        }
        public string encode(string str)//中文转utf8
        {
            Encoding utf8 = Encoding.UTF8;
            return HttpUtility.UrlEncode(str, utf8);
        }

        public virtual string writeObjectOut(string jkid, string WriteXmlDoc)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            WebReferenceAJ.Service objweb = new WebReferenceAJ.Service();
            objweb.Url = sweb;
            string msg = objweb.writeObjectOut("18", ssqm, jkid, WriteXmlDoc);
            if (msg.Contains("<code>1</code>"))
            {
                return "1";
            }
            return msg;
        }
        public virtual string SendJYXMKSSJ(string jyxm, string sbz, string gwjysbbh, string tongdao, model.安检联网.carclass objmodel)//检测项目开始和结束
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            string sksjs = "kssj";
            string sjyxx18c55 = "18C55";
            if (sbz.Contains("开始"))
            {
                sksjs = "kssj";
                luxiangkais(objmodel.jylsh, tongdao, jyxm, objmodel);//18C55录像开始
            }
            else if (sbz.Contains("结束"))
            {
                sksjs = "jssj";
                sjyxx18c55 = "18C58";
                luxiangjieshu(objmodel.jylsh, tongdao, jyxm, objmodel);//18C58录像结束
            }
            string s18C55 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
			            <vehispara>
			            <jylsh>{0}</jylsh>
			            <jyjgbh>{1}</jyjgbh>
			            <jcxdh>{2}</jcxdh>
                        <jycs>{3}</jycs>
                        <hpzl>{4}</hpzl>
                        <hphm>{5}</hphm>			            
                        <clsbdh>{6}</clsbdh>
			            <gwjysbbh>{7}</gwjysbbh>
			            <jyxm>{8}</jyxm>
			            <{10}>{9}</{11}>
			            </vehispara>
			            </root>",
                       objmodel.jylsh,
                       jyjgbh,
                       objmodel.jcxdh,
                       objmodel.jycs,
                       objmodel.hpzl.Substring(0,2),
                       encode(objmodel.hphm),
                       objmodel.clsbdh,
                       "",
                       jyxm,
                       DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                       sksjs,
                       sksjs);

            WebReferenceAJ.Service objweb = new WebReferenceAJ.Service();
            objweb.Url = sweb;
            string msg=objweb.writeObjectOut("18", ssqm, sjyxx18c55, s18C55);
            if (msg.Contains("<code>1</code>"))
            {
                return "1";
            }
            return msg;
        }
        public virtual string sendpic( string tongdao, string gongwei, model.安检联网.carclass objmodel)//抓拍指令
        {
            try
            {
                if (!ssfAJLW.Contains("是"))
                {
                    return "1";
                }
                string s18C55 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
			            <vehispara>
			            <jylsh>{0}</jylsh>
			            <jyjgbh>{1}</jyjgbh>
			            <jycs>{2}</jycs>
			            <hpzl>{3}</hpzl>
			            <hphm>{4}</hphm>
			            <tongdao>{5}</tongdao>
			            <gongwei>{6}</gongwei>
                        <xuhao>{7}</xuhao>
			            </vehispara>
			            </root>",
                                 objmodel.jylsh,
                                 jyjgbh,
                                 objmodel.jycs,
                                 objmodel.hpzl.Substring(0, 2),
                                 objmodel.hphm,
                                 tongdao,
                                 gongwei,
                                 gongwei);

                WebReferenceAJ.Service objweb = new WebReferenceAJ.Service();
                objweb.Url = sweb;
                return objweb.Picture("18", ssqm, "18C63", s18C55);
            }
            catch(Exception ex)
            {
                m_mainform.SaveErrorLog("拍照错误", ex.Message.ToString());
                return "";
            }
        }

        public virtual string sendpiczj(string tongdao, string gongwei, model.安检联网.carclass objmodel)//抓拍指令
        {
            try
            {
                if (string.IsNullOrWhiteSpace(sweb))
                {
                    return "1";
                }
                string s18C55 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
               <vehispara>
               <jylsh>{0}</jylsh>
               <jyjgbh>{1}</jyjgbh>
               <jycs>{2}</jycs>
               <hpzl>{3}</hpzl>
               <hphm>{4}</hphm>
               <tongdao>{5}</tongdao>
               <gongwei>{6}</gongwei>
                        <xuhao>{7}</xuhao>
               </vehispara>
               </root>",
                                 objmodel.jylsh,
                                 jyjgbh,
                                 objmodel.jycs,
                                 objmodel.hpzl.Substring(0, 2),
                                 objmodel.hphm,
                                 tongdao,
                                 gongwei,
                                 gongwei);

                WebReferenceAJ.Service objweb = new WebReferenceAJ.Service();
                objweb.Url = sweb;
                return objweb.Picture("18", ssqm, "18C63", s18C55);
            }
            catch (Exception ex)
            {
                m_mainform.SaveErrorLog("拍照错误", ex.Message.ToString());
                return "1";
            }
        }

        public virtual string luxiangkais(string jylsh, string tongdao, string gongwei, model.安检联网.carclass objmodel)//抓拍指令
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            string s18C55 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
			            <vehispara>
			            <jylsh>{0}</jylsh>
			            <jyjgbh>{1}</jyjgbh>
			            <jycs>{2}</jycs>
			            <hpzl>{3}</hpzl>
			            <hphm>{4}</hphm>
			            <tongdao>{5}</tongdao>
			            <gongwei>{6}</gongwei>
                        <xuhao>{7}</xuhao>
                        <jcxh>{8}</jcxh>
			            </vehispara>
			            </root>",
                             jylsh,
                             jyjgbh,
                             objmodel.jycs,
                            objmodel.hpzl.Substring(0, 2),
                             objmodel.hphm,
                             tongdao,
                             gongwei,
                             gongwei,
                             objmodel.jcxdh);

            WebReferenceAJ.Service objweb = new WebReferenceAJ.Service();
            objweb.Url = sweb;

            return objweb.video("18", ssqm, "start", s18C55);
        }
        public virtual string luxiangjieshu(string jylsh, string tongdao, string gongwei, model.安检联网.carclass objmodel)//抓拍指令
        {

            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }

            string s18C55 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
			            <vehispara>
			            <jylsh>{0}</jylsh>
			            <jyjgbh>{1}</jyjgbh>
			            <jycs>{2}</jycs>
			            <hpzl>{3}</hpzl>
			            <hphm>{4}</hphm>
			            <tongdao>{5}</tongdao>
			            <gongwei>{6}</gongwei>
                        <xuhao>{7}</xuhao>
                        <jcxh>{8}</jcxh>
			            </vehispara>
			            </root>",
                             jylsh,
                             jyjgbh,
                             objmodel.jycs,
                             objmodel.hpzl.Substring(0, 2),
                             objmodel.hphm,
                             tongdao,
                             gongwei,
                             gongwei,
                             objmodel.jcxdh);

            WebReferenceAJ.Service objweb = new WebReferenceAJ.Service();
            objweb.Url = sweb;
            return objweb.video("18", ssqm, "end", s18C55);



        }

        //public virtual string 
        public virtual string write(carclass objmodel, modelA1 objbass)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            string s18C81 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
						<vehispara>
						<jylsh>{0}</jylsh>
						<jyjgbh>{1}</jyjgbh>
						<jcxdh>{2}</jcxdh>
                        <jyxm>{3}</jyxm>
						<jycs>{4}</jycs>
						<chz>{5}</chz>
						<chpd>{6}</chpd>
						</vehispara>
						</root>",
                          objmodel.jylsh,
                          jyjgbh,
                          objmodel.jcxdh,
                          "A1",
                          objmodel.jycs,
                          objbass.chz,
                          objbass.chpd);
            //数据上传
            return writeObjectOut("18C81", s18C81);
          //  return "";
        }

        public virtual string write(carclass objmodel, modelC1 objbass)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            string s18C80 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
						<vehispara>
						<jylsh>{0}</jylsh>
						<jyjgbh>{1}</jyjgbh>
						<jcxdh>{2}</jcxdh>
                        <jyxm>{3}</jyxm>
						<jycs>{4}</jycs>
                        <hpzl>{5}</hpzl>
                        <hphm>{6}</hphm>
                        <clsbdh>{7}</clsbdh>
                        <rzxxbj>{8}</rzxxbj>
                        <rcdxbj>{9}</rcdxbj>
                        <rxsxbj>{10}</rxsxbj>
                        <rzdxbj>{11}</rzdxbj>
                        <rqtbj>{12}</rqtbj>
                        <jyyjy>{13}</jyyjy>
                        <dpjcjyy>{14}</dpjcjyy>
                        <dpjyysfzh>{15}</dpjyysfzh>
						</vehispara>
						</root>",
                          objmodel.jylsh,
                          jyjgbh,
                          objmodel.jcxdh,
                          "C1",
                          objmodel.jycs,
                          objmodel.hpzl.Substring(0, 2),
                          objmodel.hphm,
                          objmodel.clsbdh,
                          objbass.rzxxbj,
                          objbass.rcdxbj,
                          objbass.rxsxbj,
                          objbass.rzdxbj,
                          objbass.rqtbj,
                          "",
                          "test",
                          "11221");//问题problem


            return writeObjectOut("18C80", s18C80);

        }

        public virtual string write(carclass objmodel, modelB objbass, int ivax)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            //安检数据检测数据上传
            string[] zlz = { "yzzlz", "ezzlz", "sanzzlz", "sizzlz", "wzzlz" };//一轴左静态轮荷
            string[] ylz = { "yzylz", "ezylz", "sanzylz", "sizylz", "wzylz" };//一轴右静态轮荷
            string[] kzzh = { "yzkzzh", "ezkzzh", "sanzkzzh", "sizkzzh", "wzkzzh" };//一轴空载轴荷
            string[] qhzzdl = { "yzqhzzdl", "ezqhzzdl", "sanzqhzzdl", "sizqhzzdl", "wzqhzzdl" };//一轴最大左行车制动力值
            string[] qhyzdl = { "yzqhyzdl", "ezqhyzdl", "sanzqhyzdl", "sizqhyzdl", "wzqhyzdl" };//一轴最大右行车制动力值
            string[] qczzdl = { "yzqczzdl", "ezqczzdl", "sanzqczzdl", "sizqczzdl", "wzqczzdl" };//一轴最大左制动力差值

            string[] qcyzdl = { "yqqcyzdl", "ezqcyzdl", "sanzqcyzdl", "sizqcyzdl", "wzqcyzdl" };//最大右制动力差值
            string[] dll = { "yzdll", "ezdll", "sanzdll", "sizdll", "wzdll" };//行车制动率
            string[] zdlpd = { "yzzdlpd", "ezzdlpd", "sanzzdlpd", "sizzdlpd", "wzzdlpd" };//行车制动率判定
            string[] bphl = { "yzbphl", "ezbphl", "sanzbphl", "sizbphl", "wzbphl" };//不平衡率
            string[] bphlpd = { "yzbphlpd", "ezbphlpd", "sanzbphlpd", "sizbphlpd", "wzbphlpd" };//不平衡率判定
            string[] zdpd = { "yzzdpd", "ezzdpd", "sanzzdpd", "sizzdpd", "wzzdpd" };//制动判定
            string[] zldtlh = { "yzzldtlh", "ezzldtlh", "sanzzldtlh", "sizzldtlh", "wzzldtlh" };//左轮动态轮荷
            string[] yldtlh = { "yzyldtlh", "ezyldtlh", "sanzyldtlh", "sizyldtlh", "wzyldtlh" };//右轮动态轮荷
            string[] zdlqx = { "yzzdlqx", "ezzdlqx", "sanzzdlqx", "sizzdlqx", "wzzdlqx" };//制动力曲线
            string jyxm="";
            if (ivax == 0) jyxm = "B1";
            if (ivax == 1) jyxm = "B2";
            if (ivax == 2) jyxm = "B3";
            if (ivax == 3) jyxm = "B4";
            if (ivax == 4) jyxm = "B5";
            //if (ivax == 5) jyxm = "B6";
            string s18C81 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
						<vehispara>
						<jylsh>{0}</jylsh>
						<jyjgbh>{1}</jyjgbh>
						<jcxdh>{2}</jcxdh>
                        <jyxm>{3}</jyxm>
						<jycs>{4}</jycs>
						<{20}>{5}</{20}>
						<{21}>{6}</{21}>
                        <{22}>{7}</{22}>
                        <{23}>{8}</{23}>
                        <{24}>{9}</{24}>
                        <{25}>{10}</{25}>
                        <{26}>{11}</{26}>
                        <{27}>{12}</{27}>
                        <{28}>{13}</{28}>
                        <{29}>{14}</{29}>
                        <{30}>{15}</{30}>
                        <{31}>{16}</{31}>
                        <{32}>{17}</{32}>
                        <{33}>{18}</{33}>
                        <{34}>{19}</{34}>
						</vehispara>
						</root>",
                          objmodel.jylsh,
                          jyjgbh,
                          objmodel.jcxdh,
                          jyxm,
                          objmodel.jycs,
                          objbass.zlz,
                         objbass.ylz,
                         objbass.kzzh,
                         objbass.qhzzdl,
                         objbass.qhyzdl,
                         objbass.qczzdl,
                         objbass.qcyzdl,
                         objbass.dll,
                         objbass.zdlpd,
                         objbass.bphl,
                         objbass.bphlpd,
                         objbass.zdpd,
                         objbass.zldtlh,
                         objbass.yldtlh,
                         objbass.zdlqx,
                          zlz[ivax],
                          ylz[ivax],
                          kzzh[ivax],
                          qhzzdl[ivax],
                          qhyzdl[ivax],
                          qczzdl[ivax],
                          qcyzdl[ivax],
                          dll[ivax],
                          zdlpd[ivax],
                          bphl[ivax],
                          bphlpd[ivax],
                          zdpd[ivax],
                          zldtlh[ivax],
                          yldtlh[ivax],
                          zdlqx[ivax]);
            //数据上传
           
            return writeObjectOut("18C81", s18C81);
            //return "";
        }

        public virtual string write(carclass objmodel, modelB0 objbass)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            string s18C81 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
						<vehispara>
						<jylsh>{0}</jylsh>
						<jyjgbh>{1}</jyjgbh>
						<jcxdh>{2}</jcxdh>
                        <jyxm>{3}</jyxm>
						<jycs>{4}</jycs>
						<yzzczdl>{5}</yzzczdl>
						<ezzczdl>{6}</ezzczdl>
                        <sanzzczdl>{7}</sanzzczdl>
                        <sizzczdl>{8}</sizzczdl>
                        <wzzczdl>{9}</wzzczdl>
                        <zczczdl>{10}</zczczdl>
                        <tczzdl>{11}</tczzdl>
                        <tcyzdl>{12}</tcyzdl>
                        <tczdl>{13}</tczdl>
                        <tczdpd>{14}</tczdpd>
						</vehispara>
						</root>",
                    objmodel.jylsh,
                    jyjgbh,
                    objmodel.jcxdh,
                    "B0",
                    objmodel.jycs,
                    objbass.yzzczdl,
                    objbass.ezzczdl,
                    objbass.sanzzczdl,
                    objbass.sizzczdl,
                    objbass.wzzczdl,
                    objbass.zczczdl,
                    objbass.tczzdl,
                    objbass.tcyzdl,
                    objbass.tczdl,
                    objbass.tczdpd);
            //数据上传
            //writeObjectOut("18C81", s18C81);
            return writeObjectOut("18C81", s18C81);
            //return "";
        }

        public virtual string write(carclass objmodel, modelL objbass, int ivax)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            string jyxm = "";
            if (ivax == 0) jyxm = "L1";
            if (ivax == 1) jyxm = "L2";
            if (ivax == 2) jyxm = "L3";
            if (ivax == 3) jyxm = "L4";
            if (ivax == 4) jyxm = "L5";
            string s18C81 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
						<vehispara>
						<jylsh>{0}</jylsh>
						<jyjgbh>{1}</jyjgbh>
						<jcxdh>{2}</jcxdh>
                        <jyxm>{3}</jyxm>
						<jycs>{4}</jycs>
						<qhzzdl>{5}</qhzzdl>
						<qhyzdl>{6}</qhyzdl>
                        <qczzdl>{7}</qczzdl>
                        <qcyzdl>{8}</qcyzdl>
                        <dll>{9}</dll>
                        <zdlpd>{10}</zdlpd>
                        <bphl>{11}</bphl>
                        <bphlpd>{12}</bphlpd>
                        <zdpd>{13}</zdpd>
                        <zljzlh>{14}</zljzlh>
                        <yljzlh>{15}</yljzlh>
                        <zdlqx>{16}</zdlqx>
						</vehispara>
						</root>",
                          objmodel.jylsh,
                          jyjgbh,
                          objmodel.jcxdh,
                          jyxm,
                          objmodel.jycs,
                        objbass.qhzzdl,
                        objbass.qhyzdl,
                        objbass.qczzdl,
                        objbass.qcyzdl,
                        objbass.dll,
                        objbass.zdlpd,
                        objbass.bphl,
                        objbass.bphlpd,
                        objbass.zdpd,
                        objbass.zljzlh,
                        objbass.yljzlh,
                        objbass.zdlqx);
            return writeObjectOut("18C81", s18C81);
            //return "";
        }

        public virtual string write(carclass objmodel, modelH1 objbass)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            //左主灯
            string s18C81 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
						<vehispara>
						<jylsh>{0}</jylsh>
						<jyjgbh>{1}</jyjgbh>
						<jcxdh>{2}</jcxdh>
                        <jyxm>{3}</jyxm>
						<jycs>{4}</jycs>
						<zdg>{5}</zdg>
						<zwjgdg>{6}</zwjgdg>
                        <zwygqd>{7}</zwygqd>
                        <zwygqdpd>{8}</zwygqdpd>
                        <zwygszpz>{9}</zwygszpz>
                        <zjgszcz>{10}</zjgszcz>
                        <zwygczpy>{11}</zwygczpy>
                        <zwjgczpy>{12}</zwjgczpy>
                        <zwygczpypd>{13}</zwygczpypd>
                        <zwjgczpypd>{14}</zwjgczpypd>
                        <zwdpd>{15}</zwdpd>
						</vehispara>
						</root>",
                        objmodel.jylsh,
                        jyjgbh,
                        objmodel.jcxdh,
                        "H1",
                        objmodel.jycs,
                        objbass.zdg,
                        objbass.zwjgdg,
                        objbass.zwygqd,
                        objbass.zwygqdpd,
                        objbass.zwygszpz,
                        objbass.zjgszcz,
                        objbass.zwygczpy,
                        objbass.zwjgczpy,
                        objbass.zwygczpypd,
                        objbass.zwjgczpypd,
                        objbass.zwdpd);
            return writeObjectOut("18C81", s18C81);
            //return "";
        }

        public virtual string write(carclass objmodel, modelH4 objbass)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            //右主灯
            string s18C81 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
						<vehispara>
						<jylsh>{0}</jylsh>
						<jyjgbh>{1}</jyjgbh>
						<jcxdh>{2}</jcxdh>
                        <jyxm>{3}</jyxm>
						<jycs>{4}</jycs>
						<ydg>{5}</ydg>
						<ywjgdg>{6}</ywjgdg>
                        <ywygqd>{7}</ywygqd>
                        <ywygqdpd>{8}</ywygqdpd>
                        <ywygszpz>{9}</ywygszpz>
                        <yjgszcz>{10}</yjgszcz>
                        <ywygczpy>{11}</ywygczpy>
                        <ywjgczpy>{12}</ywjgczpy>
                        <ywygczpypd>{13}</ywygczpypd>
                        <ywjgczpypd>{14}</ywjgczpypd>
                        <ywdpd>{15}</ywdpd>
						</vehispara>
						</root>",
                        objmodel.jylsh,
                        jyjgbh,
                        objmodel.jcxdh,
                        "H4",
                        objmodel.jycs,
                        objbass.ydg,
                                      objbass.ywjgdg,
                                      objbass.ywygqd,
                                      objbass.ywygqdpd,
                                      objbass.ywygszpz,
                                      objbass.yjgszcz,
                                      objbass.ywygczpy,
                                      objbass.ywjgczpy,
                                      objbass.ywygczpypd,
                                      objbass.ywjgczpypd,
                                      objbass.ywdpd);
            return writeObjectOut("18C81", s18C81);
            //return "";
        }

        public virtual string write(carclass objmodel, modelS1 objbass)
        {
            if (!ssfAJLW.Contains("是"))
            {
                return "1";
            }
            string s18C81 = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
						<vehispara>
						<jylsh>{0}</jylsh>
						<jyjgbh>{1}</jyjgbh>
						<jcxdh>{2}</jcxdh>
                        <jyxm>{3}</jyxm>
						<jycs>{4}</jycs>
						<csdscz>{5}</csdscz>
						<csbpd>{6}</csbpd>
						</vehispara>
						</root>",
                          objmodel.jylsh,
                          jyjgbh,
                          objmodel.jcxdh,
                          "S1",
                          objmodel.jycs,
                          objbass.csdscz,
                          objbass.csbpd);
            //数据上传
            return writeObjectOut("18C81", s18C81);
            //return "";
        }

        public virtual string write(carclass objmodel, model18C82 model18C82)
        {
            string vehispara18C82 = "";
            string stoubao18C82 = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
            vehispara18C82 = stoubao18C82 + string.Format(@"<root><vehispara>
                            <jylsh>{0}</jylsh>
                            <jyjgbh>{1}</jyjgbh>
                            <jcxdh>{2}</jcxdh>
                            <hphm>{3}</hphm>
                            <hpzl>{4}</hpzl>
                            <clsbdh>{5}</clsbdh>
                            <ycyxm>{6}</ycyxm>
                            <ycysfzh>{7}</ycysfzh>
                             <zczdl>{8}</zczdl>
                             <zczdpd>{9}</zczdpd>
                             <zczdjyjg>{10}</zczdjyjg>
                             <zdjccs>{11}</zdjccs>
                            <zcpd>{12}</zcpd>
                            <zjccs>{13}</zjccs>
                            <jczczbzl>{14}</jczczbzl>
                            <bzzczbzl>{15}</bzzczbzl>
                            <zczbzlbfb>{16}</zczbzlbfb>
                            <zbzlpd>{17}</zbzlpd>
                            </vehispara></root>",
                       objmodel.jylsh,
                       jyjgbh,
                       objmodel.jcxdh,
                       m_mainform.encode(objmodel.hphm),
                       m_mainform.encode(objmodel.hpzl.Substring(0, 2)),
                       m_mainform.encode(objmodel.clsbdh),
                       model18C82.ycyxm,
                       "445281199501013034",//身份证
                       model18C82.zczdl,//整车制动率
                       model18C82.zczdpd,//整车制动判定
                        "0",//主车制动检验结果
                       model18C82.zdjccs,//整车制动次数
                       model18C82.zcpd,//整车判定
                       model18C82.zjccs,//总检验次数
                       model18C82.jczczbzl,//检验的整车整备质量
                       model18C82.bzzczbzl,//标准的整车整备质量
                       model18C82.zczbzlbfb,//整车整备质量百分比
                       model18C82.zbzlpd);//整备质量判定
            return writeObjectOut("18C82", vehispara18C82);
        }

        public virtual string write(carclass objmodel, model18C62 model18C62)
        {
            string vehispara18C62 = "";
            string stoubao18C62 = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
            vehispara18C62 = stoubao18C62 + string.Format(@"<root><vehispara>
                            <jylsh>{0}</jylsh>
                            <jyjgbh>{1}</jyjgbh>
                            <jcxdh>{2}</jcxdh>
                            <jycs>{3}</jycs>
                            <hphm>{4}</hphm>
                            <hpzl>{5}</hpzl>
                            <clsbdh>{6}</clsbdh>
                            <jyjl>{7}</jyjl>
                            <pzrxm>{8}</pzrxm>
                            <rgjyjgs>{9}</rgjyjgs>
                            <yqsbjyjgs>{10}</yqsbjyjgs>
                            <jybgjy>{11}</jybgjy>
                            <jybgbz>{12}</jybgbz>
                            </vehispara></root>",
                   //objmodel.jylsh,
                   //objmodel.jyjgbh,
                   //objmodel.jcxdh,
                   //objmodel.jycs,
                   //m_mainform.encode(objmodel.hphm),
                   //m_mainform.encode(objmodel.hpzl.Substring(0, 2)),
                   //m_mainform.encode(objmodel.clsbdh),
                   //m_mainform.encode(model18C62.jyjl),
                   //m_mainform.encode(model18C62.pzrxm),//问题
                   //model18C62.rgjyjgs,
                   //model18C62.yqsbjyjgs,
                   //model18C62.jybgjy,
                   //model18C62.jybgbz);
                    objmodel.jylsh,
                   objmodel.jyjgbh,
                   objmodel.jcxdh,
                   objmodel.jycs,
                   objmodel.hphm,
                   objmodel.hpzl.Substring(0, 2),
                   objmodel.clsbdh,
                   model18C62.jyjl,
                   model18C62.pzrxm,//问题
                   model18C62.rgjyjgs,
                   model18C62.yqsbjyjgs,
                   model18C62.jybgjy,
                   model18C62.jybgbz);//揭阳昂特不转码
            return writeObjectOut("18C62", vehispara18C62);
        }

        public virtual string write(carclass objmodel, modelZ1 objbass)
        { 
           string QueryXmlDoc = "";
            string stou = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
            QueryXmlDoc = stou + string.Format(@"<root>
                                                <vehispara>
                                                <jylsh>{0}</jylsh>
                                                <jyjgbh>{1}</jyjgbh>
                                                <jcxdh>{2}</jcxdh>
                                                <jyxm>{3}</jyxm>
                                                <jycs>{4}</jycs>
                                                <zbzl>{5}</zbzl>
                                                <zbzlpd>{6}</zbzlpd>
                                                </vehispara>
                                                </root>",
                                                objmodel.jylsh,
                                                objmodel.jyjgbh,
                                                objmodel.jcxdh,
                                                "Z1",
                                                objmodel.jycs,
                                                objbass.zbzl,
                                                objbass.zbzlpd);

            return writeObjectOut("18C81", QueryXmlDoc);
        }

        public virtual string write(carclass objmodel, modelM1 objbass)
        {
            string WriteXmlDoc = string.Format("<?xml version=\"1.0\" encoding=\"GBK\"?>" + @"<root>
			<vehispara>
			<jylsh>{0}</jylsh>
			<jyjgbh>{1}</jyjgbh>
			<jcxdh>{2}</jcxdh>
			<jyxm>{3}</jyxm>
			<jycs>{4}</jycs>
            <cwkc>{5}</cwkc>
            <cwkk>{6}</cwkk>
            <cwkg>{7}</cwkg>
            <clwkccpd>{8}</clwkccpd>
			</vehispara>
			</root>", objmodel.jylsh, objmodel.jyjgbh, objmodel.jcxdh, "M1", objmodel.jycs,
            objbass.cwkc, objbass.cwkk, objbass.cwkg, objbass.clwkccpd);

           return writeObjectOut("18C81", WriteXmlDoc);

        }

        public virtual string sendAJend(string jylsh, bool bbz,bool bzt)//发送检测结束
        {
            if (!ssfAJLW.Contains("是")||bzt)
            {
                return "1";
            }
            WebReferenceAJ.Service objweb = new WebReferenceAJ.Service();
            objweb.Url = sweb;

            string msg = objweb.sendAJend(jylsh, bbz);
            if (msg.Contains("<code>1</code>"))
            {
                return "1";
            }
            return msg;
        }
//        public virtual string wtiteEnd(carclass objmodel)
//        {
//            string vehispara18C59 = "";
//            string stoubao18C59 = "<?xml version=\"1.0\" encoding=\"GBK\"?>";
//            vehispara18C59 = stoubao18C59 + string.Format(@"<root><vehispara>
//                            <jylsh>{0}</jylsh>
//                            <jyjgbh>{1}</jyjgbh>
//                            <jcxdh>{2}</jcxdh>
//                            <jycs>{3}</jycs>
//                            <hpzl>{4}</hpzl>
//                            <hphm>{5}</hphm>
//                            <clsbdh>{6}</clsbdh>
//                            <jssj>{7}</jssj>
//                            </vehispara></root>",
//                objmodel.jylsh,
//                objmodel.jyjgbh,
//                m_mainform.encode(objmodel.jcxdh),
//                m_mainform.encode(objmodel.jycs),
//                m_mainform.encode(objmodel.hpzl.Substring(0, 2)),
//                 m_mainform.encode(objmodel.hphm),
//                m_mainform.encode(objmodel.clsbdh),
//                DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
//            return writeObjectOut("18C59", vehispara18C59);
//        }

    }
}
